import compression from 'vite-plugin-compression'

export default function (env) {
  const { VITE_BUILD_COMPRESS } = env
  const compressList = VITE_BUILD_COMPRESS.split(',')
  const data = {}
  if (compressList.includes('gzip')) {
    // http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
    data.ext = '.gz'
    data.deleteOriginFile = false
  }
  if (compressList.includes('brotli')) {
    data.ext = '.br'
    data.algorithm = 'brotliCompress'
    data.deleteOriginFile = false
  }
  return compression(data)
}
